<%--
  Created by IntelliJ IDEA.
  User: Jason
  Date: 2016/9/8
  Time: 11:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>客户管理</title>
    <meta charset="utf-8">
    <style>
    </style>
</head>
<body>
<jsp:include page="../basic/include.jsp"></jsp:include>
<jsp:include page="../basic/top.jsp"></jsp:include>
<jsp:include page="../basic/left.jsp"></jsp:include>
<div class="body-container">

    <c:if test="${guest_last != null}">
        <div class="alert alert-info" role="alert">
            <em>刚才创建账户:</em>
            <em>编号：</em><strong style="color: mediumvioletred;">${guest_last.guestId}</strong>
            <em>姓名：</em><strong>${guest_last.guestName}</strong>
            <em>密码：</em><strong style="color: mediumvioletred;">${guest_last.pwd}</strong>
            <em style="color: red;">【请将编号、密码发放给客户使用】</em>
        </div>
    </c:if>

    <div class="well">
        <button class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-sm">创建客户账户</button>
    </div>
    <table class="table table-hover table-striped">

        <thead>
        <tr>
            <td>编号</td>
            <td>姓名</td>
            <td>密码</td>
            <td>ip地址</td>
            <td>电脑唯一编号</td>
            <td>最后登陆时间</td>
            <td>创建时间</td>
            <td>账户有效期</td>
            <td>操作</td>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${guestList}" var="li">
            <tr>
                <td>${li.guestId}</td>
                <td>${li.guestName}</td>
                <td>${li.pwd}</td>
                <td>${li.ipAddress}</td>
                <td>${li.macAddress}</td>
                <td><fmt:formatDate value="${li.lastTime}" pattern="yyyy/MM/dd  HH:mm:ss"/></td>
                <td><fmt:formatDate value="${li.createTime}" pattern="yyyy/MM/dd  HH:mm:ss"/></td>
                <td>
                    <c:choose>
                    <c:when test="${li.untilTime == null}">无限期</c:when>
                    <c:otherwise><fmt:formatDate value="${li.untilTime}" pattern="yyyy/MM/dd  HH:mm:ss"/></td>
                </c:otherwise>
                </c:choose>

                <td>
                    <c:choose>
                        <c:when test="${li.status == 0}">
                            <a class="btn btn-xs btn-danger" href="user_guest_status.do?guestId=${li.guestId}&&guestStatus=1">置为不可用</a>
                        </c:when>
                        <c:otherwise>
                            <a class="btn btn-xs btn-success" href="user_guest_status.do?guestId=${li.guestId}&&guestStatus=0">置为可用</a>
                        </c:otherwise>
                    </c:choose>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>


    <!-- Large modal -->
    <div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg">

            <div class="modal-content" style="padding:20px;padding-bottom: 0;">
                <form class="jsForm" action="user_add_guest.do" method="post">
                    <input id="inp-js-id" type="hidden" name="jsId"/>
                    <div class="input-group">
                        <span class="input-group-addon">姓名</span>
                        <input id="guestName" name="guestName" type="text" class="form-control" placeholder="客户姓名(可以为空)">
                    </div>
                    <br>
                    <div class="input-group">
                        <span class="input-group-addon">账户有效期</span>
                        <select name="guestType" class="form-control">
                            <option selected value="0">无限期</option>
                            <option value="1">一年</option>
                        </select>
                    </div>
                    <div class="modal-footer">
                        <button type="submit" class="btn btn-primary">生成</button>
                    </div>
                </form>
            </div>

        </div>
    </div>

</div>
</body>
</html>
